(function () {
  angular.module('starter', ['ionic', 'starter.pages', 'starter.theme'])

    .run(function ($ionicPlatform, $rootScope, $ionicHistory) {
      $ionicPlatform.ready(function () {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
          cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
          cordova.plugins.Keyboard.disableScroll(true);

        }
        if (window.StatusBar) {
          // org.apache.cordova.statusbar required
          StatusBar.styleDefault();
        }
      });

      $rootScope.$saveOrGoBack = function (backCount) {
        if ($rootScope.doState.isModify) {
          $rootScope.doState.afterCall();
          $rootScope.doState.isModify = false;
        }
        $ionicHistory.goBack(backCount);
      };

      $rootScope.doState = {
        isModify: false,
        afterCall: function () {

        }
      };

      $rootScope.newPlanId = -1;

    })
    .config(function($ionicConfigProvider) {
        $ionicConfigProvider.tabs.position('bottom');
    });    
})();
